// Angular Version 6 below need to be deleted {providedIn: 'root'}

// angular
import {Injectable} from '@angular/core';
import {HttpParams} from '@angular/common/http';
// owner
import {DynClass, Request} from 'pengesoft-ng-lib';
// Angular Version 6 below need to be deleted {providedIn: 'root'}

// models
import {Employee} from '../domains/employee.domain';
// import {EmployeeDto} from '../domains/employeedto.domain';
// import {Map} from '../domains/map.domain';
// models
// import {any[]} from '../domains/any[].domain';
import {EmployeeDto} from '../domains/employeedto.domain';
import {Archives} from '../domains/archives.domain';
// import {Map} from '../domains/map.domain';

// import {Archives} from '../domains/archives.domain';

import {Resume} from '../domains/resume.domain';

/**
 * EmployeeServiceSvr
 */
@Injectable({
  providedIn: 'root'
})
export class EmployeeServiceSvr {
  baseUrl: string;

  constructor(
    private request: Request
  ){
    this.baseUrl = 'EmployeeServiceSvr.assx/';
  }

  /**
   *
   */
  getEmployeeDtoByState(stateId: string): Promise<any[]>{
    const httpParams = new HttpParams()
      .append('stateId', stateId.toString());
    return this.request.post<any[]>(this.baseUrl + 'getEmployeeDtoByState', httpParams).then((res) => {
      return res;
    });
  }

  /**
   *
   */
  updateEmployeeDto(employeeDto: EmployeeDto): Promise<number>{
    const httpParams = new HttpParams()
      .append('employeeDto', employeeDto.toString());
    return this.request.post<number>(this.baseUrl + 'updateEmployeeDto', httpParams).then((res) => {
      return res;
    });
  }

  /**
   *
   */
  getEmployeeCountByState(stateId: string): Promise<number>{
    const httpParams = new HttpParams()
      .append('stateId', stateId.toString());
    return this.request.post<number>(this.baseUrl + 'getEmployeeCountByState', httpParams).then((res) => {
      return res;
    });
  }

  /**
   *
   */
// <<<<<<< HEAD
  // addEmployee(): Promise<number>{
  //   const httpParams = new HttpParams();
  //   return this.request.post<number>(this.baseUrl + 'addEmployee', httpParams).then((res) => {
  //     return res;
  //   });
  // }

  /**
   *
   */
  getEmployeeDtoByCondition(map: DynClass): Promise<any[]>{
    const httpParams = new HttpParams()
      .append('map', map.toString());
    return this.request.post<any[]>(this.baseUrl + 'getEmployeeDtoByCondition', httpParams).then((res) => {
// =======
//   getArchivesByEmpId(empId: string): Promise<Archives>{
//     const httpParams = new FormData()
//     httpParams.append('empId', empId.toString());
//     return this.request.post<Archives>(this.baseUrl + 'getArchivesByEmpId', httpParams).then((res) => {
//       return new Archives(res);
//     });
//   }
//

//
//   /**
//    *
//    */
//   getAllEmployeeDto(): Promise<any[]>{
//     const httpParams = new HttpParams();
//     return this.request.post<any[]>(this.baseUrl + 'getAllEmployeeDto', httpParams).then((res) => {
// >>>>>>> 114a0271d9ae48d67f42c6a79764287a47013b8b
      return res;
    });
  }

  /**
   *
   */
  updateEmployee(employee: Employee): Promise<number>{
    const httpParams = new HttpParams()
      .append('employee', employee.toString());
    return this.request.post<number>(this.baseUrl + 'updateEmployee', httpParams).then((res) => {
      return res;
    });
  }

  /**
   *
   */
  myGetEmployeeDtoByCondition(map: DynClass): Promise<any[]>{
    const httpParams = new HttpParams()
      .append('map', map.toString());
    return this.request.post<any[]>(this.baseUrl + 'myGetEmployeeDtoByCondition', httpParams).then((res) => {
      return res;
    });
  }

  /**
   *
   */
  // addEmployee(): Promise<number>{
  //   const httpParams = new HttpParams();
  //   return this.request.post<number>(this.baseUrl + 'addEmployee', httpParams).then((res) => {
  //     return res;
  //   });
  // }

  /**
   *
   */
  getArchivesByEmpId(empId: string): Promise<Archives>{
    const httpParams = new HttpParams()
      .append('empId', empId.toString());
    return this.request.post<Archives>(this.baseUrl + 'getArchivesByEmpId', httpParams).then((res) => {
      return res;
    });
  }

  /**
   *
   */
  myGetEmployeeDtoByState(stateId: string): Promise<any[]>{
    const httpParams = new HttpParams()
      .append('stateId', stateId.toString());
    return this.request.post<any[]>(this.baseUrl + 'myGetEmployeeDtoByState', httpParams).then((res) => {
      return res;
    });
  }

  /**
   *
   */
  myGetAllEmployDto(): Promise<any[]>{
    const httpParams = new HttpParams();
    return this.request.post<any[]>(this.baseUrl + 'myGetAllEmployDto', httpParams).then((res) => {
      return res;
    });
  }

  /**
   *
   */
  addEmployee(resume: { InfoSource: any; ApplyType: any; Email: any; Education: any; Remarks: any; ApplyStatus: any; Tel: any; Id: any; JobId: any; ApplyWay: any; ResumeFile: any; Name: any }): Promise<number>{
    const httpParams = new HttpParams()
      .append('resume', resume.toString());
    return this.request.post<number>(this.baseUrl + 'addEmployee', httpParams).then((res) => {
      return res;
    });
  }

  /**
   *
   */
  update(empId: string, stateId: string): Promise<number>{
    const httpParams = new HttpParams()
      .append('empId', empId.toString())
      .append('stateId', stateId.toString());
    return this.request.post<number>(this.baseUrl + 'update', httpParams).then((res) => {
      return res;
    });
  }

  getEmpCount(): Promise<any>{
    const httpParams = new HttpParams();
    return this.request.post<any>(this.baseUrl + 'getEmpCount', httpParams).then((res) => {
      return res;
    });
  }


}
